module lang.d.tokens.patterns;

import lang.d.tokens.tokentype;
import lang.tokenset;

class Patterns {
    private static shared TokenType[string] KEYWORDS;
    private static shared ushort[string] NAMED_ENTITIES;
    private static shared const TokenSet KEYWORDS_SET;
    private static shared const TokenSet BASIC_TYPES_SET;
    private static shared const TokenSet BASIC_TYPE2_SET;
    private static shared const TokenSet POSTFIX_OPERATION_SET;
    private static shared const TokenSet UNARY_OPERATION_SET;
    private static shared const TokenSet MULT_OPERATION_SET;
    private static shared const TokenSet ADD_OPERATION_SET;
    private static shared const TokenSet SHIFT_OPERATION_SET;
    private static shared const TokenSet COMPARE_OPERATION_SET;
    private static shared const TokenSet AND_OPERATION_SET;
    private static shared const TokenSet XOR_OPERATION_SET;
    private static shared const TokenSet OR_OPERATION_SET;
    private static shared const TokenSet ANDAND_OPERATION_SET;
    private static shared const TokenSet OROR_OPERATION_SET;
    private static shared const TokenSet ASSIGN_OPERATION_SET;
    private static shared const TokenSet ATTRIBUTES_SET;
    private static shared const TokenSet PROTECTION_ATTRIBUTES_SET;
    private static shared const TokenSet REPAIR_SET;
    private static shared const TokenSet STORAGE_CLASSES_SET;
    private static shared const TokenSet STORAGE_CLASSES_PARENIZED_SET;
    private static shared const TokenSet DECLARATIONS_SET;
    private static shared const TokenSet INOUT_SET;
    private static shared const TokenSet FUNCTION_ATTRIBUTES_SET;
    private static shared const TokenSet MEMBER_FUNCTION_ATTRIBUTES_SET;
    private static shared const TokenSet DECLARATOR_SUFFIXES_SET;

    static this() {
        with (TokenType) {
            KEYWORDS["abstract"] = ABSTRACT;
            KEYWORDS["alias"] = ALIAS;
            KEYWORDS["align"] = ALIGN;
            KEYWORDS["asm"] = ASM;
            KEYWORDS["assert"] = ASSERT;
            KEYWORDS["auto"] = AUTO;

            KEYWORDS["body"] = BODY;
            KEYWORDS["bool"] = BOOL;
            KEYWORDS["break"] = BREAK;
            KEYWORDS["byte"] = BYTE;

            KEYWORDS["case"] = CASE;
            KEYWORDS["cast"] = CAST;
            KEYWORDS["catch"] = CATCH;
            KEYWORDS["cdouble"] = CDOUBLE;
            KEYWORDS["cent"] = CENT;
            KEYWORDS["cfloat"] = CFLOAT;
            KEYWORDS["char"] = CHAR;
            KEYWORDS["class"] = CLASS;
            KEYWORDS["const"] = CONST;
            KEYWORDS["continue"] = CONTINUE;
            KEYWORDS["creal"] = CREAL;

            KEYWORDS["dchar"] = DCHAR;
            KEYWORDS["debug"] = DEBUG;
            KEYWORDS["default"] = DEFAULT;
            KEYWORDS["delegate"] = DELEGATE;
            KEYWORDS["delete"] = DELETE;
            KEYWORDS["deprecated"] = DEPRECATED;
            KEYWORDS["do"] = DO;
            KEYWORDS["double"] = DOUBLE;

            KEYWORDS["else"] = ELSE;
            KEYWORDS["enum"] = ENUM;
            KEYWORDS["export"] = EXPORT;
            KEYWORDS["extern"] = EXTERN;

            KEYWORDS["false"] = FALSE;
            KEYWORDS["final"] = FINAL;
            KEYWORDS["finally"] = FINALLY;
            KEYWORDS["float"] = FLOAT;
            KEYWORDS["for"] = FOR;
            KEYWORDS["foreach"] = FOREACH;
            KEYWORDS["foreach_reverse"] = FOREACH_REVERSE;
            KEYWORDS["function"] = FUNCTION;

            KEYWORDS["goto"] = GOTO;

            KEYWORDS["idouble"] = IDOUBLE;
            KEYWORDS["if"] = IF;
            KEYWORDS["ifloat"] = FLOAT;
            KEYWORDS["immutable"] = IMMUTABLE;
            KEYWORDS["import"] = IMPORT;
            KEYWORDS["in"] = IN;
            KEYWORDS["int"] = INT;
            KEYWORDS["interface"] = INTERFACE;
            KEYWORDS["invariant"] = INVARIANT;
            KEYWORDS["ireal"] = IREAL;
            KEYWORDS["is"] = IS;

            KEYWORDS["lazy"] = LAZY;
            KEYWORDS["long"] = LONG;

            KEYWORDS["macro"] = MACRO;
            KEYWORDS["mixin"] = MIXIN;
            KEYWORDS["module"] = MODULE;

            KEYWORDS["new"] = NEW;
            KEYWORDS["nothrow"] = NOTHROW;
            KEYWORDS["null"] = NULL;

            KEYWORDS["out"] = OUT;
            KEYWORDS["override"] = OVERRIDE;

            KEYWORDS["package"] = PACKAGE;
            KEYWORDS["pragma"] = PRAGMA;
            KEYWORDS["private"] = PRIVATE;
            KEYWORDS["protected"] = PROTECTED;
            KEYWORDS["public"] = PUBLIC;
            KEYWORDS["pure"] = PURE;

            KEYWORDS["real"] = REAL;
            KEYWORDS["ref"] = REF;
            KEYWORDS["return"] = RETURN;

            KEYWORDS["scope"] = SCOPE;
            KEYWORDS["shared"] = SHARED;
            KEYWORDS["short"] = SHORT;
            KEYWORDS["static"] = STATIC;
            KEYWORDS["struct"] = STRUCT;
            KEYWORDS["super"] = SUPER;
            KEYWORDS["switch"] = SWITCH;
            KEYWORDS["synchronized"] = SYNCHRONIZED;

            KEYWORDS["template"] = TEMPLATE;
            KEYWORDS["this"] = THIS;
            KEYWORDS["throw"] = THROW;
            KEYWORDS["true"] = TRUE;
            KEYWORDS["try"] = TRY;
            KEYWORDS["typedef"] = TYPEDEF;
            KEYWORDS["typeid"] = TYPEID;
            KEYWORDS["typeof"] = TYPEOF;

            KEYWORDS["ubyte"] = UBYTE;
            KEYWORDS["ucent"] = UCENT;
            KEYWORDS["uint"] = UINT;
            KEYWORDS["ulong"] = ULONG;
            KEYWORDS["union"] = UNION;
            KEYWORDS["unittest"] = UNITTEST;
            KEYWORDS["ushort"] = USHORT;

            KEYWORDS["version"] = VERSION;
            KEYWORDS["void"] = VOID;

            KEYWORDS["wchar"] = WCHAR;
            KEYWORDS["while"] = WHILE;
            KEYWORDS["with"] = WITH;

            KEYWORDS["!is"] = NOTIS;

            KEYWORDS["__FILE__"] = FILE;
            KEYWORDS["__LINE__"] = LINE;
            KEYWORDS["__gshared"] = GSHARED;
            KEYWORDS["__thread"] = THREAD;
            KEYWORDS["__traits"] = TRAITS;

            BASIC_TYPES_SET = TokenSet.create(INT, CHAR, BOOL, VOID, BYTE, CDOUBLE,
                                              CENT, CFLOAT, CREAL, DCHAR,
                                              DOUBLE, FLOAT, IDOUBLE, IFLOAT,
                                              IREAL, LONG, REAL, SHORT,
                                              UBYTE, UCENT, UINT, ULONG, USHORT, WCHAR);


            BASIC_TYPE2_SET = TokenSet.create(STAR, OPEN_BRACKET, FUNCTION, DELEGATE);

            KEYWORDS_SET = TokenSet.create(ABSTRACT, ALIAS, ALIGN, ASM, ASSERT, AUTO,
                                           BODY, BOOL, BREAK, BYTE, CASE, CAST,
                                           CATCH, CDOUBLE, CENT, CFLOAT,
                                           CHAR, CLASS, CONST, CONTINUE,
                                           CREAL, DCHAR, DEBUG, DEFAULT,
                                           DELEGATE, DELETE, DEPRECATED, DO,
                                           DOUBLE, ELSE, ENUM, EXPORT,
                                           EXTERN, FALSE, FINAL, FINALLY,
                                           FLOAT, FOR, FOREACH, FOREACH_REVERSE,
                                           FUNCTION, GOTO, IDOUBLE, IF, FLOAT,
                                           IMPORT, IN, INT, INTERFACE,
                                           INVARIANT, IREAL, IS, LAZY,
                                           LONG, MACRO, MIXIN, MODULE,
                                           NEW, NOTHROW, NULL, OUT, OVERRIDE,
                                           PACKAGE, PRAGMA, PRIVATE, PROTECTED,
                                           PUBLIC, PURE, REAL, REF,
                                           RETURN, SCOPE, SHARED, SHORT,
                                           STATIC, STRUCT, SUPER, SWITCH,
                                           SYNCHRONIZED, TEMPLATE,
                                           THIS, THROW, TRUE, TRY,
                                           TYPEDEF, TYPEID, TYPEOF, UBYTE,
                                           UCENT, UINT, ULONG, UNION,
                                           UNITTEST, USHORT, VERSION, VOID,
                                           WCHAR, WHILE, WITH, NOTIS,
                                           FILE, LINE, GSHARED, THREAD, TRAITS);

            POSTFIX_OPERATION_SET = TokenSet.create(DOT, INCREMENT, DECREMENT,
                                                    OPEN_PAREN, OPEN_BRACKET);
            UNARY_OPERATION_SET = TokenSet.create(AND, INCREMENT, DECREMENT,
                                                  STAR, MINUS, PLUS, NOT, TILDE);

            MULT_OPERATION_SET = TokenSet.create(DIV, STAR, MOD);
            ADD_OPERATION_SET = TokenSet.create(PLUS, MINUS, TILDE);
            SHIFT_OPERATION_SET = TokenSet.create(SHL, SHR, SHRUNS);
            COMPARE_OPERATION_SET = TokenSet.create(EQ, NOTEQ, IS, NOTIS, IN,
                                                    LESS, LESSEQ, GREAT, GREATEQ,
                                                    NOTLESSGREATEQ, NOTLESSGREAT, LESSGREAT,
                                                    LESSGREATEQ, NOTGREAT, NOTGREATEQ,
                                                    NOTLESS, NOTLESSEQ);
            AND_OPERATION_SET = TokenSet.create(AND);
            XOR_OPERATION_SET = TokenSet.create(CARET);
            OR_OPERATION_SET = TokenSet.create(OR);
            ANDAND_OPERATION_SET = TokenSet.create(ANDAND);
            OROR_OPERATION_SET = TokenSet.create(OROR);
            ASSIGN_OPERATION_SET = TokenSet.create(ASSIGN, PLUSASS, MINUSASS,
                                                   MULTASS, DIVASS, MODASS,
                                                   ANDASS, ORASS, CARETASS,
                                                   TILDEASS, SHLASS, SHRASS, SHRUNSASS,
                                                   CARETCARETASS);

            ATTRIBUTES_SET = TokenSet.create(EXTERN, ALIGN, PRAGMA, DEPRECATED, STATIC, FINAL,
                                             PRIVATE, PACKAGE, PROTECTED, PUBLIC, EXPORT,
                                             OVERRIDE, ABSTRACT, CONST, AUTO, SCOPE, GSHARED,
                                             SHARED, IMMUTABLE);
            PROTECTION_ATTRIBUTES_SET = TokenSet.create(PRIVATE, PACKAGE, PROTECTED, PUBLIC, EXPORT);

            STORAGE_CLASSES_SET = TokenSet.create(ABSTRACT, AUTO, CONST, DEPRECATED, EXTERN,
                                                  FINAL, IMMUTABLE, SHARED, NOTHROW, OVERRIDE,
                                                  PURE, SCOPE, STATIC, SYNCHRONIZED);

            STORAGE_CLASSES_PARENIZED_SET = TokenSet.create(IMMUTABLE, CONST, SHARED);

            REPAIR_SET = TokenSet.create(SEMICOLON, CLOSE_CURLY, EOF);

            // BASIC_TYPES_SET + STORAGE_CLASSES_SET + TYPEDEF + ALIAS - FINAL - STATIC - SCOPE - SYNCHRONIZED
            DECLARATIONS_SET = TokenSet.create(INT, CHAR, BOOL, VOID, BYTE, CDOUBLE,
                                               CENT, CFLOAT, CREAL, DCHAR,
                                               DOUBLE, FLOAT, IDOUBLE, IFLOAT,
                                               IREAL, LONG, REAL, SHORT,
                                               UBYTE, UCENT, UINT, ULONG,
                                               USHORT, WCHAR, TYPEDEF, ALIAS,
                                               CONST, AUTO, EXTERN, IMMUTABLE,
                                               SHARED, PURE, NOTHROW, GSHARED,
                                               ABSTRACT, AUTO, CONST, DEPRECATED, EXTERN,
                                               IMMUTABLE, SHARED, NOTHROW, OVERRIDE, PURE);

            INOUT_SET = TokenSet.create(IN, OUT, REF, LAZY);

            FUNCTION_ATTRIBUTES_SET = TokenSet.create(PURE, NOTHROW);

            MEMBER_FUNCTION_ATTRIBUTES_SET = TokenSet.orSet(STORAGE_CLASSES_PARENIZED_SET, FUNCTION_ATTRIBUTES_SET);

            DECLARATOR_SUFFIXES_SET = TokenSet.create(OPEN_PAREN, OPEN_BRACKET);
        }

        NAMED_ENTITIES["quot"] =    34;
        NAMED_ENTITIES["amp"] =     38;
        NAMED_ENTITIES["lt"] =      60;
        NAMED_ENTITIES["gt"] =      62;
        NAMED_ENTITIES["OElig"] =   338;
        NAMED_ENTITIES["oelig"] =   339;
        NAMED_ENTITIES["Scaron"] =  352;
        NAMED_ENTITIES["scaron"] =  353;
        NAMED_ENTITIES["Yuml"] =    376;
        NAMED_ENTITIES["circ"] =    710;
        NAMED_ENTITIES["tilde"] =   732;
        NAMED_ENTITIES["ensp"] =    8194;
        NAMED_ENTITIES["emsp"] =    8195;
        NAMED_ENTITIES["thinsp"] =  8201;
        NAMED_ENTITIES["zwnj"] =    8204;
        NAMED_ENTITIES["zwj"] =     8205;
        NAMED_ENTITIES["lrm"] =     8206;
        NAMED_ENTITIES["rlm"] =     8207;
        NAMED_ENTITIES["ndash"] =   8211;
        NAMED_ENTITIES["mdash"] =   8212;
        NAMED_ENTITIES["lsquo"] =   8216;
        NAMED_ENTITIES["rsquo"] =   8217;
        NAMED_ENTITIES["sbquo"] =   8218;
        NAMED_ENTITIES["ldquo"] =   8220;
        NAMED_ENTITIES["rdquo"] =   8221;
        NAMED_ENTITIES["bdquo"] =   8222;
        NAMED_ENTITIES["dagger"] =  8224;
        NAMED_ENTITIES["Dagger"] =  8225;
        NAMED_ENTITIES["permil"] =  8240;
        NAMED_ENTITIES["lsaquo"] =  8249;
        NAMED_ENTITIES["rsaquo"] =  8250;
        NAMED_ENTITIES["euro"] =    8364;

        // Latin-1 (ISO-8859-1) Entities
        NAMED_ENTITIES["nbsp"] =    160;
        NAMED_ENTITIES["iexcl"] =   161;
        NAMED_ENTITIES["cent"] =    162;
        NAMED_ENTITIES["pound"] =   163;
        NAMED_ENTITIES["curren"] =  164;
        NAMED_ENTITIES["yen"] =     165;
        NAMED_ENTITIES["brvbar"] =  166;
        NAMED_ENTITIES["sect"] =    167;
        NAMED_ENTITIES["uml"] =     168;
        NAMED_ENTITIES["copy"] =    169;
        NAMED_ENTITIES["ordf"] =    170;
        NAMED_ENTITIES["laquo"] =   171;
        NAMED_ENTITIES["not"] =     172;
        NAMED_ENTITIES["shy"] =     173;
        NAMED_ENTITIES["reg"] =     174;
        NAMED_ENTITIES["macr"] =    175;
        NAMED_ENTITIES["deg"] =     176;
        NAMED_ENTITIES["plusmn"] =  177;
        NAMED_ENTITIES["sup2"] =    178;
        NAMED_ENTITIES["sup3"] =    179;
        NAMED_ENTITIES["acute"] =   180;
        NAMED_ENTITIES["micro"] =   181;
        NAMED_ENTITIES["para"] =    182;
        NAMED_ENTITIES["middot"] =  183;
        NAMED_ENTITIES["cedil"] =   184;
        NAMED_ENTITIES["sup1"] =    185;
        NAMED_ENTITIES["ordm"] =    186;
        NAMED_ENTITIES["raquo"] =   187;
        NAMED_ENTITIES["frac14"] =  188;
        NAMED_ENTITIES["frac12"] =  189;
        NAMED_ENTITIES["frac34"] =  190;
        NAMED_ENTITIES["iquest"] =  191;
        NAMED_ENTITIES["Agrave"] =  192;
        NAMED_ENTITIES["Aacute"] =  193;
        NAMED_ENTITIES["Acirc"] =   194;
        NAMED_ENTITIES["Atilde"] =  195;
        NAMED_ENTITIES["Auml"] =    196;
        NAMED_ENTITIES["Aring"] =   197;
        NAMED_ENTITIES["AElig"] =   198;
        NAMED_ENTITIES["Ccedil"] =  199;
        NAMED_ENTITIES["Egrave"] =  200;
        NAMED_ENTITIES["Eacute"] =  201;
        NAMED_ENTITIES["Ecirc"] =   202;
        NAMED_ENTITIES["Euml"] =    203;
        NAMED_ENTITIES["Igrave"] =  204;
        NAMED_ENTITIES["Iacute"] =  205;
        NAMED_ENTITIES["Icirc"] =   206;
        NAMED_ENTITIES["Iuml"] =    207;
        NAMED_ENTITIES["ETH"] =     208;
        NAMED_ENTITIES["Ntilde"] =  209;
        NAMED_ENTITIES["Ograve"] =  210;
        NAMED_ENTITIES["Oacute"] =  211;
        NAMED_ENTITIES["Ocirc"] =   212;
        NAMED_ENTITIES["Otilde"] =  213;
        NAMED_ENTITIES["Ouml"] =    214;
        NAMED_ENTITIES["times"] =   215;
        NAMED_ENTITIES["Oslash"] =  216;
        NAMED_ENTITIES["Ugrave"] =  217;
        NAMED_ENTITIES["Uacute"] =  218;
        NAMED_ENTITIES["Ucirc"] =   219;
        NAMED_ENTITIES["Uuml"] =    220;
        NAMED_ENTITIES["Yacute"] =  221;
        NAMED_ENTITIES["THORN"] =   222;
        NAMED_ENTITIES["szlig"] =   223;
        NAMED_ENTITIES["agrave"] =  224;
        NAMED_ENTITIES["aacute"] =  225;
        NAMED_ENTITIES["acirc"] =   226;
        NAMED_ENTITIES["atilde"] =  227;
        NAMED_ENTITIES["auml"] =    228;
        NAMED_ENTITIES["aring"] =   229;
        NAMED_ENTITIES["aelig"] =   230;
        NAMED_ENTITIES["ccedil"] =  231;
        NAMED_ENTITIES["egrave"] =  232;
        NAMED_ENTITIES["eacute"] =  233;
        NAMED_ENTITIES["ecirc"] =   234;
        NAMED_ENTITIES["euml"] =    235;
        NAMED_ENTITIES["igrave"] =  236;
        NAMED_ENTITIES["iacute"] =  237;
        NAMED_ENTITIES["icirc"] =   238;
        NAMED_ENTITIES["iuml"] =    239;
        NAMED_ENTITIES["eth"] =     240;
        NAMED_ENTITIES["ntilde"] =  241;
        NAMED_ENTITIES["ograve"] =  242;
        NAMED_ENTITIES["oacute"] =  243;
        NAMED_ENTITIES["ocirc"] =   244;
        NAMED_ENTITIES["otilde"] =  245;
        NAMED_ENTITIES["ouml"] =    246;
        NAMED_ENTITIES["divide"] =  247;
        NAMED_ENTITIES["oslash"] =  248;
        NAMED_ENTITIES["ugrave"] =  249;
        NAMED_ENTITIES["uacute"] =  250;
        NAMED_ENTITIES["ucirc"] =   251;
        NAMED_ENTITIES["uuml"] =    252;
        NAMED_ENTITIES["yacute"] =  253;
        NAMED_ENTITIES["thorn"] =   254;
        NAMED_ENTITIES["yuml"] =    255;

        // Symbols and Greek letter entities
        NAMED_ENTITIES["fnof"] =    402;
        NAMED_ENTITIES["Alpha"] =   913;
        NAMED_ENTITIES["Beta"] =    914;
        NAMED_ENTITIES["Gamma"] =   915;
        NAMED_ENTITIES["Delta"] =   916;
        NAMED_ENTITIES["Epsilon"] = 917;
        NAMED_ENTITIES["Zeta"] =    918;
        NAMED_ENTITIES["Eta"] =     919;
        NAMED_ENTITIES["Theta"] =   920;
        NAMED_ENTITIES["Iota"] =    921;
        NAMED_ENTITIES["Kappa"] =   922;
        NAMED_ENTITIES["Lambda"] =  923;
        NAMED_ENTITIES["Mu"] =      924;
        NAMED_ENTITIES["Nu"] =      925;
        NAMED_ENTITIES["Xi"] =      926;
        NAMED_ENTITIES["Omicron"] = 927;
        NAMED_ENTITIES["Pi"] =      928;
        NAMED_ENTITIES["Rho"] =     929;
        NAMED_ENTITIES["Sigma"] =   931;
        NAMED_ENTITIES["Tau"] =     932;
        NAMED_ENTITIES["Upsilon"] = 933;
        NAMED_ENTITIES["Phi"] =     934;
        NAMED_ENTITIES["Chi"] =     935;
        NAMED_ENTITIES["Psi"] =     936;
        NAMED_ENTITIES["Omega"] =   937;
        NAMED_ENTITIES["alpha"] =   945;
        NAMED_ENTITIES["beta"] =    946;
        NAMED_ENTITIES["gamma"] =   947;
        NAMED_ENTITIES["delta"] =   948;
        NAMED_ENTITIES["epsilon"] = 949;
        NAMED_ENTITIES["zeta"] =    950;
        NAMED_ENTITIES["eta"] =     951;
        NAMED_ENTITIES["theta"] =   952;
        NAMED_ENTITIES["iota"] =    953;
        NAMED_ENTITIES["kappa"] =   954;
        NAMED_ENTITIES["lambda"] =  955;
        NAMED_ENTITIES["mu"] =      956;
        NAMED_ENTITIES["nu"] =      957;
        NAMED_ENTITIES["xi"] =      958;
        NAMED_ENTITIES["omicron"] = 959;
        NAMED_ENTITIES["pi"] =      960;
        NAMED_ENTITIES["rho"] =     961;
        NAMED_ENTITIES["sigmaf"] =  962;
        NAMED_ENTITIES["sigma"] =   963;
        NAMED_ENTITIES["tau"] =     964;
        NAMED_ENTITIES["upsilon"] = 965;
        NAMED_ENTITIES["phi"] =     966;
        NAMED_ENTITIES["chi"] =     967;
        NAMED_ENTITIES["psi"] =     968;
        NAMED_ENTITIES["omega"] =   969;
        NAMED_ENTITIES["thetasym"] = 977;
        NAMED_ENTITIES["upsih"] =   978;
        NAMED_ENTITIES["piv"] =     982;
        NAMED_ENTITIES["bull"] =    8226;
        NAMED_ENTITIES["hellip"] =  8230;
        NAMED_ENTITIES["prime"] =   8242;
        NAMED_ENTITIES["Prime"] =   8243;
        NAMED_ENTITIES["oline"] =   8254;
        NAMED_ENTITIES["frasl"] =   8260;
        NAMED_ENTITIES["weierp"] =  8472;
        NAMED_ENTITIES["image"] =   8465;
        NAMED_ENTITIES["real"] =    8476;
        NAMED_ENTITIES["trade"] =   8482;
        NAMED_ENTITIES["alefsym"] = 8501;
        NAMED_ENTITIES["larr"] =    8592;
        NAMED_ENTITIES["uarr"] =    8593;
        NAMED_ENTITIES["rarr"] =    8594;
        NAMED_ENTITIES["darr"] =    8595;
        NAMED_ENTITIES["harr"] =    8596;
        NAMED_ENTITIES["crarr"] =   8629;
        NAMED_ENTITIES["lArr"] =    8656;
        NAMED_ENTITIES["uArr"] =    8657;
        NAMED_ENTITIES["rArr"] =    8658;
        NAMED_ENTITIES["dArr"] =    8659;
        NAMED_ENTITIES["hArr"] =    8660;
        NAMED_ENTITIES["forall"] =  8704;
        NAMED_ENTITIES["part"] =    8706;
        NAMED_ENTITIES["exist"] =   8707;
        NAMED_ENTITIES["empty"] =   8709;
        NAMED_ENTITIES["nabla"] =   8711;
        NAMED_ENTITIES["isin"] =    8712;
        NAMED_ENTITIES["notin"] =   8713;
        NAMED_ENTITIES["ni"] =      8715;
        NAMED_ENTITIES["prod"] =    8719;
        NAMED_ENTITIES["sum"] =     8721;
        NAMED_ENTITIES["minus"] =   8722;
        NAMED_ENTITIES["lowast"] =  8727;
        NAMED_ENTITIES["radic"] =   8730;
        NAMED_ENTITIES["prop"] =    8733;
        NAMED_ENTITIES["infin"] =   8734;
        NAMED_ENTITIES["ang"] =     8736;
        NAMED_ENTITIES["and"] =     8743;
        NAMED_ENTITIES["or"] =      8744;
        NAMED_ENTITIES["cap"] =     8745;
        NAMED_ENTITIES["cup"] =     8746;
        NAMED_ENTITIES["int"] =     8747;
        NAMED_ENTITIES["there4"] =  8756;
        NAMED_ENTITIES["sim"] =     8764;
        NAMED_ENTITIES["cong"] =    8773;
        NAMED_ENTITIES["asymp"] =   8776;
        NAMED_ENTITIES["ne"] =      8800;
        NAMED_ENTITIES["equiv"] =   8801;
        NAMED_ENTITIES["le"] =      8804;
        NAMED_ENTITIES["ge"] =      8805;
        NAMED_ENTITIES["sub"] =     8834;
        NAMED_ENTITIES["sup"] =     8835;
        NAMED_ENTITIES["nsub"] =    8836;
        NAMED_ENTITIES["sube"] =    8838;
        NAMED_ENTITIES["supe"] =    8839;
        NAMED_ENTITIES["oplus"] =   8853;
        NAMED_ENTITIES["otimes"] =  8855;
        NAMED_ENTITIES["perp"] =    8869;
        NAMED_ENTITIES["sdot"] =    8901;
        NAMED_ENTITIES["lceil"] =   8968;
        NAMED_ENTITIES["rceil"] =   8969;
        NAMED_ENTITIES["lfloor"] =  8970;
        NAMED_ENTITIES["rfloor"] =  8971;
        NAMED_ENTITIES["lang"] =    9001;
        NAMED_ENTITIES["rang"] =    9002;
        NAMED_ENTITIES["loz"] =     9674;
        NAMED_ENTITIES["spades"] =  9824;
        NAMED_ENTITIES["clubs"] =   9827;
        NAMED_ENTITIES["hearts"] =  9829;
        NAMED_ENTITIES["diams"] =   9830;
    }

    private this() {
    }

    public static bool isKeyword(in string name) {
        return ((name in KEYWORDS) !is null);
    }

    public static bool isKeyword(in TokenType type) {
        return type in KEYWORDS_SET;
    }

    public static TokenType getKeywordToken(in string name) {
        return KEYWORDS[name];
    }

    public static bool isNamedEntity(in string name) {
        return ((name in NAMED_ENTITIES) !is null);
    }

    public static char getNamedEntitySymbol(in string name) {
        return cast(char) NAMED_ENTITIES[name];
    }
}
